package br.livro.android.cap4;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ExemploListyActivity1 extends ListActivity {

	@Override
	public void onCreate(Bundle icicle){
		super.onCreate(icicle);
		//array de strings
		String[] itens = new String[] {"Nome 1", "Nome 2", "Nome 3", "Nome 1", "Nome 2", "Nome 3", "Nome 1", "Nome 2", "Nome 3"};
		
		ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, itens);
		
		setListAdapter(arrayAdapter);
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id){
		super.onListItemClick(l,v,position,id);
		
		//pega o item naquela posicao
		Object o = this.getListAdapter().getItem(position);
		String item = o.toString();
		Toast.makeText(this, "Voce selecionou: " + item, Toast.LENGTH_SHORT).show();
		
	}
	
	
	
}
